<template>
    <div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center">
        <div>
            <div style="font-size: 5vh">身份识别......</div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            userType: 'admin',
            form: {
                user: "admin",
                password: "admin",
                autologin: false
            },
            rules: {
                user: [
                    { required: true, message: this.$t('login.userError'), trigger: 'blur' }
                ],
                password: [
                    { required: true, message: this.$t('login.PWError'), trigger: 'blur' }
                ]
            },
            islogin: false,
            ambient: '',
            user: {},
            url: '',
            code: '无数据',
            agentid: 0,
            menu: '',
            haha: ''
        }
    },
    async mounted() {
		//企业微信 链接写法
		//https://ocr.chem-family.com:1888/scui/?AgentId=1000024#/
        this.$q.loading.show()
		this.$TOOL.data.clear()

		this.url = window.location.href
		this.ambient = process.env.NODE_ENV
		if (this.ambient === "production") {
			this.code = this.$TOOL.urlExtract(window.location.href, "code");
			this.agentid = this.$TOOL.urlExtract(window.location.href, "AgentId");
			this.menu = this.$TOOL.urlExtract(window.location.href, "menu");
			var e = await this.$API.weixin.GetUserByCode.get(this.code, this.agentid);
			this.haha = e;
			this.user = e;
			var f = { "userId": "1", "userName": "Administrator", "dashboard": "0", "role": ["SA", "admin", "Auditor"] };
			f.userName = e.name;
			f.avatar=e.avatar;
			f.userId=e.userid;
			this.$TOOL.data.set("USER_INFO", f);
		} else {
			var d = await this.$API.weixin.GetUserById.get('shaj', '108');
			this.user = d;
			var b = { "userId": "1", "userName": "Administrator", "dashboard": "0","role": ["SA", "admin", "Auditor"] };
			b.userName = d.name;
			b.avatar=d.avatar;
			b.userId=d.userid;
			this.$TOOL.data.set("USER_INFO", b);
			//this.menu="admin";
			//this.menu="rl";
			this.menu="ns";
			//this.menu="cw";
			//this.menu="crm";
			//this.menu="gongzi";
			//this.menu="free";
		}

		var c = "SCUI.Administrator.Auth";

		this.$TOOL.cookie.set("TOKEN", c, {
			expires: 12 * 60 * 60
		})

		this.menu=this.menu+"_menu";
		var a = await await this.$API.menu.GetMenu.get(this.menu);
		if(a.code==500){
			var url=this.menu+'.json';
			const localMenu = await import('@/menu/'+url);
            a = localMenu.default;
			this.$TOOL.data.set("MENU", a.data.menu);
			this.$TOOL.data.set("PERMISSIONS", a.data.permissions);
			this.$TOOL.data.set("DASHBOARDGRID", a.data.dashboardGrid);
		}else{
			this.$TOOL.data.set("MENU", a.data.menu);
			this.$TOOL.data.set("PERMISSIONS", a.data.permissions);
			this.$TOOL.data.set("DASHBOARDGRID", a.data.dashboardGrid);
		}
        this.$q.loading.hide();
		this.$router.replace({
			path: '/layout'
		})


	},
}
</script>

<style></style>
